package com.ys.erp.entity.data.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author minamiyama
 * @date 2025/5/27 15:38
 */
@Data
@Accessors(chain = true)
@TableName("t_mall_home_activity_coupons")
public class MallHomeActivityCoupons {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("activity_no")
    private String activityNo;


    /**
     * 活动ID
     */
    @TableField("activity_id")
    private Long activityId;

    /**
     * 优惠券ID列表（逗号分隔）
     */
    @TableField("coupons_id")
    private Long couponsId;

    /**
     * 发放方式
     */
    @TableField("send_method")
    private String sendMethod;

    /**
     * 发放数量
     */
    @TableField("send_num")
    private Long sendNum;

    /**
     * 领用规则
     */
    @TableField("adopt_rule")
    private String adoptRule;

    /**
     * 是否定时抢券（0 否，1 是）
     */
    @TableField("is_timing")
    private Integer isTiming;


    @TableField("timing_rule")
    private String timingRule;
    /**
     * 是否下单自动发券（0 否，1 是）
     */
    @TableField("is_auto")
    private Integer isAuto;

    /**
     * 版本号
     */
    @TableField("version")
    private Integer version;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;


    @Data
    public static class AdoptRuleDTO {

        private String type;

        private String num;

    }

    @Data
    @Schema(description = "定时规则对象")
    public static class TimingRuleDTO {

        @Schema(description = "定时规则类型 day 按天 week 按周 ")
        private String type;

        @Schema(description = "周几 按天无值 按照周穿周几")
        private String week;

        @Schema(description = "定时时间")
        private String time;


    }


    @AllArgsConstructor
    @Getter
    public enum Enums {

        FIXED_TOTAL, DAILY,BY_DAY, BY_TIMES;

    }

    public static final Map<String, String> ENUM_MAP = new HashMap<>();

    static {
        ENUM_MAP.put(Enums.FIXED_TOTAL.toString(), "固定总量");
        ENUM_MAP.put(Enums.DAILY.toString(), "按天发放");
        ENUM_MAP.put(Enums.BY_DAY.toString(), "按天");
        ENUM_MAP.put(Enums.BY_TIMES.toString(), "按次");
    }
}
